import 'dart:async';

import 'package:factoryside/api/api.dart';
import 'package:factoryside/bean/addr_entity.dart';
import 'package:factoryside/bean/area_list_entity.dart';
import 'package:factoryside/bean/city_list_entity.dart';
import 'package:factoryside/bean/district_list_entity.dart';
import 'package:factoryside/bean/province_list_entity.dart';
import 'package:factoryside/generated/json/addr_entity_helper.dart';
import 'package:factoryside/generated/json/area_list_entity_helper.dart';
import 'package:factoryside/generated/json/city_list_entity_helper.dart';
import 'package:factoryside/generated/json/district_list_entity_helper.dart';
import 'package:factoryside/generated/json/province_list_entity_helper.dart';
import 'package:factoryside/utils/request_util.dart';



class OrderService {
  ///  获取省
  static Future<ProvinceListEntity> getProvince(
      ) async {
    var response = await RequestUtil.post(Api.getProvince,
        {
        }
    );
    return provinceListEntityFromJson(ProvinceListEntity(), response);
  }
  ///  获取市
  static Future<CityListEntity> getCity(
      String parentCode
      ) async {
    var response = await RequestUtil.post(Api.getCity,
        {
          'ParentCode': parentCode
        }
    );
    return cityListEntityFromJson(CityListEntity(), response);
  }
  ///  获取区
  static Future<AreaListEntity> getArea(
      int parentCode
      ) async {
    var response = await RequestUtil.post(Api.getArea,
        {
          'ParentCode': parentCode
        }
    );
    return areaListEntityFromJson(AreaListEntity(), response);
  }
  ///  获取街道
  static Future<DistrictListEntity> getDistrict(
      int parentCode
      ) async {
    var response = await RequestUtil.post(Api.getDistrict,
        {
          'ParentCode': parentCode
        }
    );
    return districtListEntityFromJson(DistrictListEntity(), response);
  }
  ///获取收货地址
  static Future<AddrEntity> getAccountAddress() async {
    var response = await RequestUtil.post(Api.getAccountAddress,
        {
          'UserID': Api.userName
        }
    );
    return addrEntityFromJson(AddrEntity(), response);
  }
}
